package com.inool.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.inool.common.result.Result;
import com.inool.service.UserService;
import com.inool.model.User;
import com.inool.vo.LoginVo;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "用户管理")
@RestController
@RequestMapping("/api/user")
public class UserController {
    
    @Autowired
    private UserService userService;

    @Operation(summary = "获取用户信息")    
    @PostMapping("get-user-info")
    public Result<Map<String,Object>> getUserInfo(@RequestBody LoginVo loginVo) {
      
        return Result.ok(userService.login(loginVo));
    }

    @Operation(summary = "分页查询用户")
    @GetMapping("page")
    public Result<IPage<User>> pageUsers(@RequestParam long current, @RequestParam long size) {
        IPage<User> page = new Page<>(current, size);
        IPage<User> list = userService.pageUsers(page);
        return Result.ok(list);
    }

}
